#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @FileName  :take_over_really_browser.py
# @Time      :2024/3/4 22:08
# @Author    :Sherlock
from playwright.sync_api import sync_playwright

# ./Google\ Chrome --remote-debugging-port=8899 --incognito --start-maximized --user-data-dir="/Users/yy/Documents/code_project/webSpider/study_follow_luffycity/brow_data"
with sync_playwright() as playwright:
    brow = playwright.chromium.connect_over_cdp("http://localhost:8899")

    page = brow.contexts[0].pages[0]
    page.goto("https:www.baidu.com")
    page.locator('//*[@id="kw"]').press_sequentially("playwright", delay=500)

    print(page.url)
    print(page.title())
